package cn.com.jenson.web.car.controller;

import cn.com.jenson.common.BasicController;
import cn.com.jenson.common.ImportVerifierVo;
import cn.com.jenson.common.Result;
import cn.com.jenson.common.SelectVo;
import cn.com.jenson.dao.car.bo.CarBo;
import cn.com.jenson.dao.car.searchBo.CarSearchBo;
import cn.com.jenson.dao.car.vo.CarVo;
import cn.com.jenson.service.car.service.CarService;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/api/car")
public class CarController implements BasicController<CarVo, CarBo, CarSearchBo> {

    @Resource
    private CarService carService;

    @Override
    public Result<Page<CarVo>> pageAll(@RequestBody CarSearchBo carSearchBo) {
        return Result.suc(carService.pageAll(carSearchBo));
    }

    @Override
    public Result<List<CarVo>> listAll(@RequestBody CarSearchBo carSearchBo) {
        return Result.suc(carService.listAll(carSearchBo));
    }

    @Override
    public Result<CarVo> get(@RequestBody CarSearchBo carSearchBo) throws InstantiationException, IllegalAccessException {
        return Result.suc(carService.get(carSearchBo));
    }

    @Override
    public Result<CarVo> edit(@RequestBody CarBo carBo) throws InstantiationException, IllegalAccessException {
        return Result.suc(carService.edit(carBo));
    }

    @Override
    public Result<List<CarVo>> editAll(@RequestBody List<CarBo> carBos) {
        return Result.suc(carService.editAll(carBos));
    }

    @Override
    public Result<CarVo> deleted(@RequestBody CarSearchBo carSearchBo) throws InstantiationException, IllegalAccessException {
        return Result.suc(carService.deleted(carSearchBo));
    }

    @Override
    public Result<List<CarVo>> deletedAll(@RequestBody List<CarSearchBo> carSearchBos) throws InstantiationException, IllegalAccessException {
        return Result.suc(carService.deletedAll(carSearchBos));
    }

    @Override
    public List<ImportVerifierVo> importTemplateVerifiers() {
        return null;
    }

    @Override
    public void importTemplateDownload(HttpServletResponse response) throws IOException {

    }

    @Override
    public Result<List<SelectVo<String, Integer, CarVo>>> option() {
        return null;
    }
}
